<!DOCTYPE html>
<title>Test that a detached TextTrackList can still be used without crashing.</title>
<script src="../../resources/gc.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
    var video = document.createElement("video");

    // Register an event handler on video element's TextTrackList.
    var tracks = video.textTracks;
    tracks.onaddtrack = handler;

    // Clear "video" to bring about its release.
    video = null;

    // Force garbage collection.
    gc();

    setTimeout(t.step_func_done(function() {
        // Inspect and invoke the handler.
        assert_equals(tracks.onaddtrack, handler);
        tracks.onaddtrack();
    }), 0);

    function handler() {
        // PASS (no crash).
    }
});
</script>